Skip to content

Fix Swoole thread context handling for NTS builds - #1229

Merged
crazywhalecc merged 1 commit into
v3from
fix/swoole-thread-context
Aug 13, 2026
Merged

Fix Swoole thread context handling for NTS builds#1229
crazywhalecc merged 1 commit into
v3from
fix/swoole-thread-context

Conversation

@crazywhalecc

Copy link
Copy Markdown
Owner

What does this PR do?

swoole thread mode (multi-threading) requires ZTS. Our chosen swoole-thread and thread-context are mutually exclusive, because thread-context uses process-global state (a single lock and reactor pointer), which conflicts with multi-reactor thread mode. For NTS builds, just use the upstream default (boost asm context): it is faster and better tested.

Enabling thread-context on NTS is known to cause segfaults, e.g. Process::signal() in onManagerStart. I will submit the real patch upstream later.

Checklist before merging

  • If you modified *.php or *.yml, run them locally to ensure your changes are valid:
    • composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:lint-config

@github-actions

Copy link
Copy Markdown

StaticPHP Test Bot

Detected: Extensions: swoole | Libraries: none | Targets: none
Active labels: none
Available labels: need-test (gate), test/linux test/windows test/macos (platform), test/tier2 (extra arch), test/php-83 test/php-84 (PHP version), sapi/frankenphp (extra FrankenPHP SAPI build)
Config: Linux x86_64 + Windows x86_64 + macOS arm64 | PHP 8.5 NTS

@henderkes

Copy link
Copy Markdown
Collaborator

The swoole team is usually very fast fixing these kinds of things, worth looking if they can't fix it quick before we lose the capability.

@crazywhalecc

Copy link
Copy Markdown
Owner Author

Looks like --enable-thread-context is slower than --disable-thread-context. Its more suitable for debugging compatibility, so even if the upstream is fixed, continuing to use --disable-thread-context on NTS is still the correct choice (config.m4 also disables it by default).

@crazywhalecc
crazywhalecc merged commit cf5471b into v3 Aug 13, 2026
17 checks passed
@crazywhalecc
crazywhalecc deleted the fix/swoole-thread-context branch August 13, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-test This PR has not been tested yet, cannot merge now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants